package de.ghost23.common.process {

	/**
	* Defines a step in a BranchProcess. Consists of the ICommand, that should be
	* executed at this step and zero to many Followers, that are defined as possible
	* successors of this step.
	* @author Sven Busse
	* @version 1.0
	* @see de.ghost23.common.process.Follower
	*/

	public class Step {

		/**
		 * The defined ICommand. It is recommended to extend DialogCommand.
		 */
		private var _command:Class;
		
		/**
		 * An array of Followers or an empty array.
		 * @see de.ghost23.common.process.Follower
		 */
		private var _followers:Array;
		
		/**
		 * Constructs a new Step for a BranchProcess.
		 * @param	command The ICommand, that should be executed at this step. It is recommended to extend ACommand.
		 * Note, this should be a reference to the class directly, not a class instance!
		 * @param	followers An array of Follower instances, or an empty array, if there should be no followers.
		 */
		public function Step(command:Class, followers:Array=null) {
			_command = command;
			if(followers != null) _followers = followers;
			else _followers = new Array();
		}
		
		/**
		 * Returns the defined ICommand for this step.
		 */
		public function get command():Class {
			return _command;
		}
		
		/**
		 * Returns the array of Followers for this step or an empty
		 * array, depending on what was defined.
		 * @see de.ghost23.common.process.Follower
		 */
		public function get followers():Array {
			return _followers;
		}
		
		/**
		 * Adds a new Follower to the array of defined Followers.
		 * @param	newFollower The new Follower. Will be added at the end of this list, although the
		 * order is not important.
		 * @see de.ghost23.common.process.Follower
		 */
		public function pushFollower(newFollower:Follower):void {
			
			_followers.push(newFollower);
		}
	}
}